from email.mime.text import MIMEText
from email.header import Header
from email import encoders
from email.utils import parseaddr,formataddr
import smtplib


# from_addr=input('From:')
# password=input('Password：')
# to_addr=input('To:')
# smtp_server=input('SMTP server:')
from_addr='380410203@qq.com'
password='vskdocgzwdtebiec'
to_addr='zhang_yue_qin@163.com'
smtp_server='smtp.qq.com'

def _format_addr(s):
	name,addr=parseaddr(s)
	return formataddr((Header(name,'utf-8').encode(),addr))

msg=MIMEText('hello,send bu Python...','plain','utf-8')
msg['From']=_format_addr('发送者<%s>'%from_addr)
msg['To']=_format_addr('接收者<%s>'%to_addr)
msg['Subject']=Header('发送邮件测试……','utf-8').encode()

server=smtplib.SMTP(smtp_server,25)
server.set_debuglevel(1)
server.login(from_addr,password)
server.sendmail(from_addr,[to_addr],msg.as_string())
server.quit()